package com.tfy.liquor.service.impl;

import com.tfy.liquor.service.SnowFlakeService;
import com.tfy.liquor.util.SnowFlake;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

// 雪花算法生成id
@Service
public class SnowFlakeServiceImpl implements SnowFlakeService {
    // 生成默认id
    @Override
    public Long getDefaultId() {
        SnowFlake idWorker = new SnowFlake(0, 0);
        return idWorker.nextId();
    }

    // 传入工作id和数据中心id获取id
    @Override
    public Long getId(Long workerId, Long datacenterId) {
        SnowFlake idWorker = new SnowFlake(workerId, datacenterId);
        return idWorker.nextId();
    }
}
